package org.bit.lesson06;

public class SingletonDCL {

    private static volatile SingletonDCL instance;

    private SingletonDCL() {
    }

    /**
     * 对外提供一个获取对象的方法
     *
     * @return
     */
    public static SingletonDCL getInstance() {
        // 第一次判断是否需要加锁
        if (instance == null) {
            synchronized (SingletonDCL.class) {
                if (instance == null) {
                    instance = new SingletonDCL();
                }
            }
        }
        return instance;
    }
}
